package com.echoplots.shardingjdbc.service.impl;

import javax.annotation.Resource;

import org.apache.shardingsphere.api.hint.HintManager;
import org.springframework.stereotype.Service;

import com.echoplots.shardingjdbc.dao.OrderMapper;
import com.echoplots.shardingjdbc.pojo.Order;
import com.echoplots.shardingjdbc.service.OrderService;

@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Override
    public void save(Order order) {
        orderMapper.save(order);
    }
    
	@Override
	public Order selectByPrimaryKey(Long id) {
		return orderMapper.selectByPrimaryKey(id);
	}
	
	
	@Override
	public Order selectByPrimaryKeyAndMerchant(Order order) {
		return orderMapper.selectByPrimaryKeyAndMerchant(order);
	}
	
	@Override
	public Order selectByPrimaryKeyAndNoColMerchant(Order order) {
		HintManager hintManager = HintManager.getInstance();
		hintManager.addDatabaseShardingValue(order.getMerchant(), 1);
		return orderMapper.selectByPrimaryKeyAndNoColMerchant(order);
	}
}
